import { defHttp } from "/@/utils/http/axios";
import { LeaderWorkModel, ScoreModel } from "/@/api/model/practicalModel";

enum Api {
  SetLeaderWorkScore = "/leaderWork/setScore",
  GetLeaderWorkScore = "/leaderWork/getScore",
  GetLeaderWorkInfo = "/leaderWork/getInfo",
  SetLeaderWorkRemark = "/leaderWork/setRemark",
  SaveOrUpdateLeaderWork = "/leaderWork/saveOrUpdate",
}

export const getLeaderWorkInfoApi = () =>
  defHttp.get<LeaderWorkModel>({ url: Api.GetLeaderWorkInfo });

export const getLeaderWorkInfoByUserIdApi = (userId: number) =>
  defHttp.get<LeaderWorkModel>({ url: `${Api.GetLeaderWorkInfo}/${userId}` });

export const getLeaderWorkScoreApi = (userId: number) =>
  defHttp.get<ScoreModel>({ url: `${Api.GetLeaderWorkScore}/${userId}` });

export const setLeaderWorkScoreApi = (userId: number, schScore: number, univScore: number) =>
  defHttp.put<void>({
    url: `${Api.SetLeaderWorkScore}/${userId}`,
    params: { schScore, univScore },
  });

export const setLeaderWorkRemarkApi = (userId: number, content: string) =>
  defHttp.put<void>({ url: `${Api.SetLeaderWorkRemark}/${userId}`, params: { content } });

export const saveOrUpdateLeaderWorkApi = (leaderWork: LeaderWorkModel) =>
  defHttp.post<void>({ url: Api.SaveOrUpdateLeaderWork, params: leaderWork });
